using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
using OracleInternal.ServiceObjects;
using OracleInternal.SqlAndPlsqlParser.LocalParsing;

namespace OracleInternal.Common
{
	internal class SQLMetaData
	{
		internal const string IDENTIFIER_MAXSIZE = "128";

		internal const string OBJ_TYPE_MAXSIZE = "23";

		internal short m_noOfColumns;

		internal int m_maxRowSize;

		internal int m_numOfLOBColumns;

		internal int m_numOfLONGColumns;

		internal int m_numOfBFileColumns;

		internal int m_numOfJSONColumns;

		internal int m_numOfCLOBCols;

		internal int m_numOfBLOBCols;

		internal byte[] m_describeInfoHash;

		internal ColumnDescribeInfo[] m_columnDescribeInfo;

		internal Type[] m_fieldTypes;

		internal SQLLocalParsePrimaryKeyInfo m_sqlMetaInfo = SQLLocalParsePrimaryKeyInfo.Null;

		internal bool bGotDescribeInfoFromDB;

		internal bool bPkFetched;

		internal bool bStmtParsed;

		internal object m_syncPK = new object();

		internal object m_syncLP = new object();

		internal string pCommandText;

		internal bool m_bHasLOBOrLongColumn;

		internal bool m_bHasJSONColumn;

		internal bool m_bHasLOBOrLongColumnChecked;

		internal bool m_bIsInitialLongFetchSizeInChars;

		internal IEnumerable<OracleLpStatement> parsedStmt;

		internal bool m_bHasBFILEColumn;

		internal bool m_bHasBFILEColumnChecked;

		internal static string pSqlBlock1 = "DECLARE tab_name\t  VARCHAR2(128); tab_owner  VARCHAR2(128); syn_name\t  VARCHAR2(128); syn_owner  VARCHAR2(128); db_link_name  VARCHAR2(128); col_name_qry VARCHAR2(512); obj_t      VARCHAR2(23); depth      NUMBER; max_depth  NUMBER; BEGIN depth     := 0; max_depth := 10; tab_name  := ";

		internal static string pSqlBlock2 = "; tab_owner := ";

		internal static string pSqlBlock3a = "; LOOP BEGIN select ot into obj_t FROM (select object_type ot from all_objects";

		internal static string pSqlBlock3b = " where object_name = tab_name and owner = tab_owner) WHERE ROWNUM <= 1; IF (obj_t != 'SYNONYM') THEN EXIT; END IF; EXCEPTION WHEN NO_DATA_FOUND THEN obj_t := null; END; syn_name := tab_name; syn_owner:= tab_owner; select c1, c2, c3 into tab_name, tab_owner, db_link_name FROM (select table_name c1, COALESCE(table_owner, ' ') c2, COALESCE(db_link, ' ') c3 from all_synonyms";

		internal static string pSqlBlock3c = " where synonym_name = syn_name and owner in (syn_owner, 'PUBLIC') order by decode(owner, 'PUBLIC', 2, 1)) WHERE ROWNUM <= 1; IF (tab_owner = ' ' AND db_link_name != ' ') THEN select username into tab_owner from all_db_links where DB_LINK = db_link_name; EXIT; END IF; IF (depth = max_depth) THEN RAISE NO_DATA_FOUND; END IF; depth := depth + 1; END LOOP; ";

		internal static string pSqlBlock4 = "open :3 for SELECT c1, c2, c3 FROM (SELECT acc.column_name c1, acc.constraint_name c2, ac.constraint_type c3 FROM all_cons_columns acc,  all_constraints ac WHERE (ac.constraint_type = 'P' OR ac.constraint_type = 'U') AND ac.table_name = tab_name AND ac.owner = tab_owner AND ac.table_name = acc.table_name AND ac.owner = acc.owner AND ac.constraint_name = acc.constraint_name UNION SELECT aic.column_name c1, ai.index_name c2, 'U' c3 FROM all_indexes ai,  all_ind_columns aic WHERE ai.uniqueness = 'UNIQUE' AND ai.table_name = tab_name AND ai.table_owner= tab_owner AND ai.table_name = aic.table_name AND ai.table_owner = aic.table_owner AND ai.index_name = aic.index_name AND ai.owner = aic.index_owner ) ORDER BY 3, 2, 1; END;";

		internal static string pSqlBlock4_01 = "open :3 for SELECT c1, c2, c3 FROM (SELECT acc.column_name c1, acc.constraint_name c2, ac.constraint_type c3 FROM all_cons_columns acc, all_tab_cols atc, all_constraints ac WHERE (ac.constraint_type = 'P' OR ac.constraint_type = 'U') AND ac.table_name = tab_name AND ac.owner = tab_owner AND ac.table_name = acc.table_name AND ac.owner = acc.owner AND ac.constraint_name = acc.constraint_name AND ac.table_name = atc.table_name AND atc.virtual_column = 'NO' AND acc.column_name = atc.column_name UNION SELECT aic.column_name c1, ai.index_name c2, 'U' c3 FROM all_indexes ai, all_tab_cols atc, all_ind_columns aic WHERE ai.uniqueness = 'UNIQUE' AND ai.table_name = tab_name AND ai.table_owner= tab_owner AND ai.table_name = aic.table_name AND ai.table_owner = aic.table_owner AND ai.index_name = aic.index_name AND ai.owner = aic.index_owner AND ai.table_name = atc.table_name AND atc.virtual_column = 'NO' AND aic.column_name = atc.column_name) ORDER BY 3, 2, 1; END;";

		internal static string pSqlBlock4_updated = "open :3 for SELECT c1, c2, c3 FROM (SELECT acc.column_name c1, acc.constraint_name c2, ac.constraint_type c3 FROM all_cons_columns acc, all_constraints ac WHERE (ac.constraint_type = 'P' OR ac.constraint_type = 'U') AND ac.table_name = tab_name AND ac.owner = tab_owner AND ac.table_name = acc.table_name AND ac.owner = acc.owner AND ac.constraint_name = acc.constraint_name AND acc.column_name IN ( SELECT column_name FROM all_tab_cols WHERE table_name = tab_name AND virtual_column = 'NO' ) UNION SELECT aic.column_name c1, ai.index_name c2, 'U' c3 FROM all_indexes ai, all_ind_columns aic WHERE ai.uniqueness = 'UNIQUE' AND ai.table_name = tab_name AND ai.table_owner= tab_owner AND ai.table_name = aic.table_name AND ai.table_owner = aic.table_owner AND ai.index_name = aic.index_name AND ai.owner = aic.index_owner AND aic.column_name IN ( SELECT column_name FROM all_tab_cols WHERE table_name = tab_name AND virtual_column = 'NO' ) ) ORDER BY 3, 2, 1; END;";

		internal static string pSqlBlock5 = "; select username into tab_owner from all_db_links where DB_LINK=";

		internal static string pSqlBlock6 = " for select column_name, owner, table_name, hidden_column from all_tab_cols";

		internal static string pSqlBlock7 = "open ";

		internal static string pSqlBlock8 = " where owner=tab_owner and table_name=tab_name;";

		internal static string pSqlBlock9 = "\nEND;";

		internal static string pSqlBlock10 = " syn_name := NULL; syn_owner := NULL; obj_t := NULL; depth := 0; max_depth := 10;";

		internal static string pSqlBlock11 = ":{0}";

		internal static string pSqlBlock12 = " tab_name  := ";

		internal static string pSqlBlock13 = "; tab_owner := ";

		internal static string pSqlBlock14 = " if (db_link_name != ' ') THEN ";

		internal static string pSqlBlock18 = " col_name_qry := 'select column_name, owner, table_name, hidden_column from all_tab_cols' || '@' || db_link_name || ' where table_name = ''' || tab_name || ''' AND owner = ''' || tab_owner || ''''; ";

		internal static string pSqlBlock15 = " for col_name_qry; ";

		internal static string pSqlBlock16 = " ELSE ";

		internal static string pSqlBlock17 = " END IF; ";

		internal bool IsInitialLongFetchSizeInChars
		{
			get
			{
				if (HasLOBOrLongColumn)
				{
					return m_bIsInitialLongFetchSizeInChars;
				}
				return false;
			}
		}

		internal bool HasLOBColumns
		{
			get
			{
				if (!m_bHasLOBOrLongColumnChecked)
				{
					_ = HasLOBOrLongColumn;
				}
				if (m_numOfCLOBCols + m_numOfBLOBCols > 0)
				{
					return true;
				}
				return false;
			}
		}

		internal bool HasBFILEColumn
		{
			get
			{
				if (!m_bHasBFILEColumnChecked)
				{
					if (m_columnDescribeInfo != null && m_columnDescribeInfo.Length != 0)
					{
						for (int i = 0; i < m_columnDescribeInfo.Length; i++)
						{
							if (114 == m_columnDescribeInfo[i].m_dataType)
							{
								m_numOfBFileColumns++;
								m_bHasBFILEColumn = true;
							}
						}
					}
					m_bHasBFILEColumnChecked = true;
				}
				return m_bHasBFILEColumn;
			}
		}

		internal bool HasLOBOrLongColumn
		{
			get
			{
				if (!m_bHasLOBOrLongColumnChecked)
				{
					if (m_columnDescribeInfo != null && m_columnDescribeInfo.Length != 0)
					{
						for (int i = 0; i < m_columnDescribeInfo.Length; i++)
						{
							if (112 == m_columnDescribeInfo[i].m_dataType)
							{
								m_numOfLOBColumns++;
								m_numOfCLOBCols++;
								m_bHasLOBOrLongColumn = true;
							}
							else if (113 == m_columnDescribeInfo[i].m_dataType)
							{
								m_numOfLOBColumns++;
								m_numOfBLOBCols++;
								m_bHasLOBOrLongColumn = true;
							}
							else if (8 == m_columnDescribeInfo[i].m_dataType || 24 == m_columnDescribeInfo[i].m_dataType)
							{
								m_numOfLONGColumns++;
								m_bHasLOBOrLongColumn = true;
								if (8 == m_columnDescribeInfo[i].m_dataType)
								{
									m_bIsInitialLongFetchSizeInChars = true;
								}
							}
						}
					}
					m_bHasLOBOrLongColumnChecked = true;
				}
				return m_bHasLOBOrLongColumn;
			}
		}

		internal bool HasJSONColumn => m_bHasJSONColumn;

		internal static bool GetPrimaryKey(OracleConnection conn, SQLMetaData sqlMetaData, int hiddenColumnCount, bool bSchemaTable)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.SQLMetaData, OracleTraceFuncName.GetPrimaryKey);
			}
			try
			{
				if (sqlMetaData == null)
				{
					return false;
				}
				if (sqlMetaData.bPkFetched)
				{
					return true;
				}
				if (sqlMetaData.m_noOfColumns == 0)
				{
					if (sqlMetaData.m_sqlMetaInfo == null)
					{
						sqlMetaData.m_sqlMetaInfo = SQLLocalParsePrimaryKeyInfo.Null;
					}
					return false;
				}
				lock (sqlMetaData.m_syncPK)
				{
					try
					{
						if (sqlMetaData.bPkFetched)
						{
							return true;
						}
						if (!string.IsNullOrWhiteSpace(sqlMetaData.pCommandText) && conn.m_oracleConnectionImpl.m_cs.m_metadataPooling && conn.m_oracleConnectionImpl.m_pm.TryRetrievePrimaryKeyInfoFromCache(conn.m_oracleConnectionImpl.ServiceName, sqlMetaData.pCommandText, ref sqlMetaData))
						{
							return true;
						}
						if (!sqlMetaData.bStmtParsed)
						{
							SQLParser.GetSchemaMetaData(sqlMetaData, conn, conn.m_oracleConnectionImpl, hiddenColumnCount > 0);
						}
						short noOfColumns = sqlMetaData.m_noOfColumns;
						short num = (short)(sqlMetaData.m_noOfColumns - hiddenColumnCount);
						if (sqlMetaData.m_sqlMetaInfo == SQLLocalParsePrimaryKeyInfo.Null || sqlMetaData.m_sqlMetaInfo == null)
						{
							sqlMetaData.m_sqlMetaInfo = new SQLLocalParsePrimaryKeyInfo(noOfColumns);
						}
						SQLLocalParsePrimaryKeyInfo sqlMetaInfo = sqlMetaData.m_sqlMetaInfo;
						bool[] array = new bool[noOfColumns];
						bool[] array2 = new bool[noOfColumns];
						bool flag = false;
						bool flag2 = false;
						for (short num2 = 0; num2 < noOfColumns; num2 = (short)(num2 + 1))
						{
							ColumnLocalParsePrimaryKeyInfo columnLocalParsePrimaryKeyInfo = sqlMetaInfo.m_columnMetaInfo[num2];
							if (columnLocalParsePrimaryKeyInfo.m_columnName != null && (columnLocalParsePrimaryKeyInfo.m_columnName == "ROWID" || columnLocalParsePrimaryKeyInfo.m_columnName == "\"ROWID\""))
							{
								sqlMetaInfo.m_columnMetaInfo[num2].bIsUnique = true;
								array[num2] = true;
								flag2 = true;
								if (num2 < num)
								{
									flag = true;
								}
							}
						}
						if (flag2 && !bSchemaTable)
						{
							for (int i = 0; i < noOfColumns; i++)
							{
								sqlMetaInfo.m_columnMetaInfo[i].bIsKeyColumn = array[i];
							}
							sqlMetaInfo.bRowidPresent = true;
							return true;
						}
						StringBuilder stringBuilder = null;
						if (sqlMetaInfo.m_tableName == null || sqlMetaInfo.m_tableName.Length == 0)
						{
							sqlMetaData.bPkFetched = (sqlMetaData.m_sqlMetaInfo.bPkFetched = true);
							return true;
						}
						stringBuilder = new StringBuilder(pSqlBlock1);
						stringBuilder.Append(":1");
						stringBuilder.Append(pSqlBlock2);
						if (sqlMetaInfo.m_schemaName != null && sqlMetaInfo.m_schemaName.Length != 0)
						{
							stringBuilder.Append(":2");
						}
						else
						{
							stringBuilder.Append("user");
						}
						stringBuilder.Append(pSqlBlock3a);
						stringBuilder.Append(pSqlBlock3b);
						stringBuilder.Append(pSqlBlock3c);
						stringBuilder.Append(pSqlBlock4);
						OracleCommand oracleCommand = conn.CreateCommand();
						oracleCommand.CommandText = stringBuilder.ToString();
						OracleParameter oracleParameter = new OracleParameter(":1", OracleDbType.Varchar2, ParameterDirection.Input);
						oracleParameter.Value = sqlMetaInfo.m_tableName;
						oracleCommand.Parameters.Add(oracleParameter);
						OracleParameter oracleParameter2 = null;
						if (sqlMetaInfo.m_schemaName != null && sqlMetaInfo.m_schemaName.Length != 0)
						{
							oracleParameter2 = new OracleParameter(":2", OracleDbType.Varchar2, ParameterDirection.Input);
							oracleParameter2.Value = sqlMetaInfo.m_schemaName;
							oracleCommand.Parameters.Add(oracleParameter2);
						}
						OracleParameter oracleParameter3 = new OracleParameter(":3", OracleDbType.RefCursor, ParameterDirection.Output);
						oracleCommand.Parameters.Add(oracleParameter3);
						try
						{
							oracleCommand.ExecuteNonQuery();
						}
						catch (Exception ex)
						{
							sqlMetaData.bPkFetched = (sqlMetaData.m_sqlMetaInfo.bPkFetched = true);
							oracleParameter.Dispose();
							oracleParameter2?.Dispose();
							oracleParameter3.Dispose();
							oracleCommand.Dispose();
							if (ProviderConfig.m_bTraceLevelPrivate)
							{
								Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.SQLMetaData, OracleTraceFuncName.GetPrimaryKey, "SQLMetaData::GetPrimaryKey() failed. -" + ex.Message);
							}
							return false;
						}
						string text = null;
						string text2 = null;
						string text3 = null;
						bool flag3 = false;
						OracleDataReader dataReader = (oracleParameter3.Value as OracleRefCursor).GetDataReader();
						if (dataReader.Read())
						{
							text = dataReader[0] as string;
							text2 = dataReader[1] as string;
							text3 = dataReader[2] as string;
						}
						else
						{
							flag3 = true;
						}
						bool flag4 = false;
						bool flag5 = false;
						bool flag6 = conn.m_shardKey != null;
						while (!flag3)
						{
							string text4 = text;
							string text5 = text2;
							string text6 = text3;
							if (flag6 && text4 == "SYS_HASHVAL")
							{
								if (dataReader.Read())
								{
									text = dataReader[0] as string;
									text2 = dataReader[1] as string;
									text3 = dataReader[2] as string;
								}
								else
								{
									flag3 = true;
								}
								continue;
							}
							bool flag7 = true;
							bool flag8 = true;
							bool flag9 = false;
							bool flag10 = false;
							int j;
							for (j = 0; j < noOfColumns; j++)
							{
								ColumnLocalParsePrimaryKeyInfo columnLocalParsePrimaryKeyInfo2 = sqlMetaInfo.m_columnMetaInfo[j];
								if (columnLocalParsePrimaryKeyInfo2.m_columnName == null || columnLocalParsePrimaryKeyInfo2.m_columnName.Length == 0)
								{
									continue;
								}
								bool flag11 = columnLocalParsePrimaryKeyInfo2.m_columnName[0] == '"';
								if (columnLocalParsePrimaryKeyInfo2.m_columnName.Length - (flag11 ? 2 : 0) == text4.Length && string.Compare(columnLocalParsePrimaryKeyInfo2.m_columnName, flag11 ? 1 : 0, text4, 0, text4.Length) == 0)
								{
									if (!sqlMetaData.m_columnDescribeInfo[j].m_isNullAllowed)
									{
										flag8 = false;
									}
									else
									{
										flag7 = false;
									}
									flag9 = true;
									break;
								}
							}
							if (!flag9)
							{
								while (!flag3 && text2 == text5 && text3 == text6)
								{
									do
									{
										if (dataReader.Read())
										{
											text = dataReader[0] as string;
											text2 = dataReader[1] as string;
											text3 = dataReader[2] as string;
											continue;
										}
										flag3 = true;
										break;
									}
									while (flag6 && text == "SYS_HASHVAL");
								}
								continue;
							}
							do
							{
								if (dataReader.Read())
								{
									text = dataReader[0] as string;
									text2 = dataReader[1] as string;
									text3 = dataReader[2] as string;
									continue;
								}
								flag3 = true;
								break;
							}
							while (flag6 && text == "SYS_HASHVAL");
							if (flag3 || text5 != text2 || text6 != text3)
							{
								if (flag7)
								{
									if (!flag4)
									{
										array2[j] = true;
										flag10 = true;
									}
									sqlMetaInfo.m_columnMetaInfo[j].bIsUnique = true;
									for (j++; j < noOfColumns; j++)
									{
										ColumnLocalParsePrimaryKeyInfo columnLocalParsePrimaryKeyInfo3 = sqlMetaInfo.m_columnMetaInfo[j];
										if (columnLocalParsePrimaryKeyInfo3.m_columnName == null || columnLocalParsePrimaryKeyInfo3.m_columnName.Length == 0)
										{
											continue;
										}
										bool flag11 = columnLocalParsePrimaryKeyInfo3.m_columnName[0] == '"';
										if (columnLocalParsePrimaryKeyInfo3.m_columnName.Length - (flag11 ? 2 : 0) == text4.Length && string.Compare(columnLocalParsePrimaryKeyInfo3.m_columnName, flag11 ? 1 : 0, text4, 0, text4.Length) == 0 && !sqlMetaData.m_columnDescribeInfo[j].m_isNullAllowed)
										{
											if (!flag4)
											{
												array2[j] = true;
												flag10 = true;
											}
											sqlMetaInfo.m_columnMetaInfo[j].bIsUnique = true;
										}
									}
									flag4 = true;
								}
							}
							else
							{
								array2[j] = true;
								for (j++; j < noOfColumns; j++)
								{
									ColumnLocalParsePrimaryKeyInfo columnLocalParsePrimaryKeyInfo4 = sqlMetaInfo.m_columnMetaInfo[j];
									if (columnLocalParsePrimaryKeyInfo4.m_columnName == null || columnLocalParsePrimaryKeyInfo4.m_columnName.Length == 0)
									{
										continue;
									}
									bool flag11 = columnLocalParsePrimaryKeyInfo4.m_columnName[0] == '"';
									if (columnLocalParsePrimaryKeyInfo4.m_columnName.Length - (flag11 ? 2 : 0) == text4.Length && string.Compare(columnLocalParsePrimaryKeyInfo4.m_columnName, flag11 ? 1 : 0, text4, 0, text4.Length) == 0)
									{
										if (!sqlMetaData.m_columnDescribeInfo[j].m_isNullAllowed)
										{
											flag8 = false;
										}
										else
										{
											flag7 = false;
										}
										array2[j] = true;
									}
								}
								while (!flag3 && text2 == text5 && text3 == text6)
								{
									if (flag9)
									{
										flag9 = false;
										for (j = 0; j < noOfColumns; j++)
										{
											ColumnLocalParsePrimaryKeyInfo columnLocalParsePrimaryKeyInfo5 = sqlMetaInfo.m_columnMetaInfo[j];
											if (columnLocalParsePrimaryKeyInfo5.m_columnName == null || columnLocalParsePrimaryKeyInfo5.m_columnName.Length == 0)
											{
												continue;
											}
											bool flag11 = columnLocalParsePrimaryKeyInfo5.m_columnName[0] == '"';
											if (columnLocalParsePrimaryKeyInfo5.m_columnName.Length - (flag11 ? 2 : 0) == text.Length && string.Compare(columnLocalParsePrimaryKeyInfo5.m_columnName, flag11 ? 1 : 0, text, 0, text.Length) == 0)
											{
												if (!sqlMetaData.m_columnDescribeInfo[j].m_isNullAllowed)
												{
													flag8 = false;
												}
												else
												{
													flag7 = false;
												}
												array2[j] = true;
												flag9 = true;
											}
										}
									}
									do
									{
										if (dataReader.Read())
										{
											text = dataReader[0] as string;
											text2 = dataReader[1] as string;
											text3 = dataReader[2] as string;
											continue;
										}
										flag3 = true;
										break;
									}
									while (flag6 && text == "SYS_HASHVAL");
								}
								if (flag9)
								{
									if (!flag4 && flag7)
									{
										flag10 = true;
										flag4 = true;
									}
									if (!flag4 && !flag5 && !flag8)
									{
										flag10 = true;
										flag5 = true;
									}
								}
							}
							if (flag10)
							{
								Array.Copy(array2, array, noOfColumns);
							}
							Array.Clear(array2, 0, noOfColumns);
						}
						oracleParameter.Dispose();
						oracleParameter2?.Dispose();
						oracleParameter3.Dispose();
						dataReader.Dispose();
						oracleCommand.Dispose();
						if (flag3)
						{
							for (int k = 0; k < noOfColumns; k++)
							{
								sqlMetaInfo.m_columnMetaInfo[k].bIsKeyColumn = array[k];
							}
							if (flag4 || flag5 || flag)
							{
								sqlMetaInfo.bPkPresent = true;
							}
							if (!flag4 && !flag5 && flag2)
							{
								sqlMetaInfo.bRowidPresent = true;
							}
							sqlMetaData.bPkFetched = (sqlMetaData.m_sqlMetaInfo.bPkFetched = true);
							return true;
						}
					}
					finally
					{
						if (sqlMetaData.bPkFetched && conn.m_oracleConnectionImpl.m_cs.m_metadataPooling)
						{
							conn.m_oracleConnectionImpl.m_pm.TryCacheLocalParsePrimaryKeyInfo(conn.m_oracleConnectionImpl.ServiceName, sqlMetaData.pCommandText, sqlMetaData);
						}
					}
				}
				return false;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.SQLMetaData, OracleTraceFuncName.GetPrimaryKey);
				}
			}
		}

		internal void CalculateRowSize()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.SQLMetaData, OracleTraceFuncName.CalculateRowSize);
			}
			try
			{
				bool hasBFILEColumn = HasBFILEColumn;
				bool hasLOBOrLongColumn = HasLOBOrLongColumn;
				bool hasJSONColumn = HasJSONColumn;
				if (!(hasBFILEColumn || hasLOBOrLongColumn || hasJSONColumn) || m_maxRowSize != 0)
				{
					return;
				}
				for (int i = 0; i < m_noOfColumns; i++)
				{
					if (m_columnDescribeInfo[i].m_dataType != 112 && m_columnDescribeInfo[i].m_dataType != 113 && m_columnDescribeInfo[i].m_dataType != 119 && m_columnDescribeInfo[i].m_dataType != 8 && m_columnDescribeInfo[i].m_dataType != 24 && m_columnDescribeInfo[i].m_dataType != 114)
					{
						m_maxRowSize += m_columnDescribeInfo[i].m_maxLength;
					}
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.SQLMetaData, OracleTraceFuncName.CalculateRowSize);
				}
			}
		}
	}
}
